<template>
  <div class="wrapper">
    <div class="position">
      <span class="iconfont position__icon">&#xe619;</span>
      {{ address }}
      <span class="iconfont position_notice">&#xe60b;</span>
    </div>
    <div class="search">
      <span class="iconfont">&#xe62d;</span>
      <span class="search__text">{{ searchText }}</span>
    </div>
    <div class="banner">
      <img class="banner__img" src="http://www.dell-lee.com/imgs/vue3/banner.jpg" />
    </div>
    <div class="icons">
      <div class="icons__item" v-for="item in iconsList" :key="item.desc">
        <img class="icons__item__img" :src="`http://www.dell-lee.com/imgs/vue3/${item.imgName}.png`" />
        <p class="icons__item__desc">{{ item.desc }}</p>
      </div>
    </div>
    <div class="gap"></div>
    <div class="nearby">
      <h3 class="nearby__title">附近店铺</h3>
      <div class="nearby__item" v-for="item in nearbyList" :key="item.id">
        <img :src="item.imgUrl" class="nearby__item__img">
        <div class="nearby__content">
          <div class="nearby__content__title">{{ item.title }}</div>
          <div class="nearby__content__tags">
            <span class="nearby__content__tag" v-for="(innerItem, innerIndex) in item.tags" :key="innerIndex">{{
                innerItem
            }}</span>
          </div>
          <p class="nearby__content__highlight">{{ item.desc }}</p>
        </div>
      </div>
    </div>
  </div>
  <div class="docker">
    <div
      v-for="(item, index) in dockerList"
      :class="{'docker__item': true, 'docker__item--active': index === 0}"
      :key="item.icon"
    >
      <div class="iconfont" v-html="item.icon" ></div>
      <div class="docker__title">{{item.text}}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeView',
  data () {
    return {
      address: '北京理工大学国防科技园2号楼10层',
      searchText: '山姆会员商店优惠商品',
      iconsList: [
        { imgName: '超市', desc: '超市便利' },
        { imgName: '菜市场', desc: '菜市场' },
        { imgName: '水果店', desc: '水果店' },
        { imgName: '鲜花', desc: '鲜花绿植' },
        { imgName: '医药健康', desc: '医药健康' },
        { imgName: '家居', desc: '家居时尚' },
        { imgName: '蛋糕', desc: '烘培蛋糕' },
        { imgName: '签到', desc: '签到' },
        { imgName: '大牌免运', desc: '大牌免运' },
        { imgName: '红包', desc: '红包套餐' }
      ],
      nearbyList: {
        1: {
          id: 1,
          imgUrl: 'http://www.dell-lee.com/imgs/vue3/near.png',
          title: '沃尔玛',
          tags: ['月售1万+', '起送¥0', '基础运费¥5'],
          desc: 'VIP尊享满89元减4元运费券（每月3张）'
        },
        2: {
          id: 2,
          imgUrl: 'http://www.dell-lee.com/imgs/vue3/near.png',
          title: '沃尔玛2',
          tags: ['月售1万+', '起送¥0', '基础运费¥5'],
          desc: 'VIP尊享满89元减4元运费券（每月3张）'
        }
      },
      dockerList: [
        { icon: '&#xe6f3;', text: '首页' },
        { icon: '&#xe7e5;', text: '购物车' },
        { icon: '&#xe61e;', text: '订单' },
        { icon: '&#xe660;', text: '我的' }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../../style/viriables.scss";
@import "../../style/mixins.scss";

.wrapper {
  overflow-y: auto;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0.5rem;
  right: 0;
  padding: 0 0.18rem 0.1rem 0.18rem;
}

.position {
  position: relative;
  padding: 0.16rem 0.24rem 0.16rem 0;
  line-height: 0.22rem;
  font-size: 0.16rem;
  @include ellipsis;

  .position__icon {
    position: relative;
    top: 0.01rem;
    font-size: 0.2rem;
  }

  .position_notice {
    position: absolute;
    right: 0;
    top: 0.17rem;
    font-size: 0.2rem;
  }

  color: $content-fontcolor;
}

.search {
  margin-bottom: 0.12rem;
  line-height: 0.32rem;
  background: #f5f5f5;
  color: #b7b7b7;
  border-radius: 0.16rem;

  .iconfont {
    display: inline-block;
    padding: 0 0.08rem 0 0.16rem;
    font-size: 0.16rem;
  }

  &__text {
    display: inline-block;
    font-size: 0.14rem;
  }
}

.banner {
  height: 0;
  overflow: hidden;
  padding-bottom: 25.4%;

  &__img {
    width: 100%;
  }
}

.icons {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0.16rem;

  &__item {
    width: 20%;

    &__img {
      display: block;
      width: 0.4rem;
      height: 0.4rem;
      margin: 0 auto;
    }

    &__desc {
      margin: 0.06rem 0 0.16rem 0;
      text-align: center;
      color: $content-fontcolor;
    }
  }
}

.gap {
  margin: 0 -0.18rem;
  height: 0.1rem;
  background: $content-bgColor;
}

.nearby {
  &__title {
    margin: 0.16rem 0 0.02rem 0;
    font-size: 0.18rem;
    font-weight: normal;
    color: $content-fontcolor;
  }

  &__item {
    display: flex;
    padding-top: 0.12rem;

    &__img {
      margin-right: 0.16rem;
      width: 0.56rem;
      height: 0.56rem;
    }
  }

  &__content {
    flex: 1;
    padding-bottom: 0.12rem;
    border-bottom: 1px solid $content-bgColor;

    &__title {
      line-height: 0.22rem;
      font-size: 0.16rem;
      color: $content-fontcolor;
    }

    &__tags {
      margin-top: 0.08rem;
      line-height: 0.18rem;
      font-size: 0.13rem;
      color: $content-fontcolor;
    }

    &__tag {
      margin-right: 0.16rem;
    }

    &__highlight {
      margin: 0.08rem 0 0 0;
      line-height: 0.18rem;
      font-size: 0.13rem;
      color: #e93b3b;
    }
  }
}

.docker {
  display: flex;
  box-sizing: border-box;
  position: absolute;
  padding: 0 0.18rem;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0.49rem;
  border-top: 0.01rem solid $content-bgColor;
  color: $content-fontcolor;

  &__item {
    flex: 1;
    text-align: center;

    .iconfont {
      margin: 0.07rem 0 0.02rem 0;
      font-size: 0.18rem;
    }

    &--active {
      color: #1fa4fc;
    }
  }

  &__title {
    font-size: 0.2rem;
    transform: scale(0.5, 0.5);
    transform-origin: center top;
  }
}
</style>
